package leetcode.offer_two_special.linked;

/**
 * @author mazouri
 * @create 2021-09-06 23:24
 */
public class _24_reverseList {
    public ListNode reverseList(ListNode head) {
        ListNode pre = null;
        ListNode next = null;

        while (head!=null){
            //在head改变next时保存一下
            next = head.next;
            head.next = pre;
            pre = head;
            head = next;
        }
        return pre;
    }
}
